{{ indent * level }}{{ decode_comment }}
{{ indent * level }}if ({{ type_array_len }} < {{ type_define }})
{{ indent * level }}{
{{ indent * (level + 1) }}error = exi_basetypes_decoder_nbit_uint(stream, 1, &eventCode);
{{ indent * (level + 1) }}if (error == 0)
{{ indent * (level + 1) }}{
{{ indent * (level + 2) }}if (eventCode == 0)
{{ indent * (level + 2) }}{
{{ indent * (level + 3) }}uint32_t value;
{{ indent * (level + 3) }}error = exi_basetypes_decoder_nbit_uint(stream, {{ bits_to_decode }}, &value);
{{ indent * (level + 3) }}if (error == 0)
{{ indent * (level + 3) }}{
{{ indent * (level + 4) }}{{ type_value }}[{{ type_array_len }}] = ({{ type_enum }})value;
{{ indent * (level + 4) }}{{ type_array_len }}++;
{{ indent * (level + 3) }}}
{{ indent * (level + 2) }}}
{{ indent * (level + 2) }}else
{{ indent * (level + 2) }}{
{{ indent * (level + 3) }}// second level event is not supported
{{ indent * (level + 3) }}error = EXI_ERROR__UNSUPPORTED_SUB_EVENT;
{{ indent * (level + 2) }}}
{{ indent * (level + 1) }}}
{{ indent * level }}}
{{ indent * level }}else
{{ indent * level }}{
{{ indent * (level + 1) }}error = EXI_ERROR__ARRAY_OUT_OF_BOUNDS;
{{ indent * level }}}
{{ indent * level }}// if nothing went wrong, the error of exi_basetypes_decoder_nbit_uint is evaluated here
{{ indent * level }}if (error == 0)
{{ indent * level }}{
{{ indent * (level + 1) }}// END Element for simple type
{{ indent * (level + 1) }}error = exi_basetypes_decoder_nbit_uint(stream, 1, &eventCode);
{{ indent * (level + 1) }}if (error == 0)
{{ indent * (level + 1) }}{
{{ indent * (level + 2) }}if (eventCode == 0)
{{ indent * (level + 2) }}{
{%- if type_option == 1 %}
{{ indent * (level + 3) }}{{ type_value }}_isUsed = 1u;
{%- endif %}
{{ indent * (level + 3) }}grammar_id = {{ next_grammar_id }};
{{ indent * (level + 2) }}}
{{ indent * (level + 2) }}else
{{ indent * (level + 2) }}{
{{ indent * (level + 3) }}error = EXI_ERROR__DEVIANTS_NOT_SUPPORTED;
{{ indent * (level + 2) }}}
{{ indent * (level + 1) }}}
{{ indent * level }}}
